"""
认证工具模块
"""
from fastapi import Depends, HTTPException, status
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from typing import Optional

security = HTTPBearer()

async def get_current_user(
    credentials: HTTPAuthorizationCredentials = Depends(security)
) -> Optional[dict]:
    """获取当前用户信息
    
    Args:
        credentials: HTTP授权凭证
        
    Returns:
        用户信息字典
        
    Raises:
        HTTPException: 认证失败时抛出
    """
    # 这里实现基本的认证逻辑
    # 实际项目中应该验证token并返回用户信息
    # 当前只返回一个模拟用户
    
    return {
        "id": "test-user",
        "username": "tester",
        "roles": ["user"]
    }